package com.chunguang.netty.listener;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.springframework.beans.BeanUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

import com.chunguang.netty.comon.Client;
import com.chunguang.netty.comon.MainThread;
import com.chunguang.netty.comon.QueueSiglon;
import com.chunguang.netty.domain.RequestData;
import com.chunguang.netty.domain.TransferData;
import com.chunguang.netty.service.RequestDataService;

import io.netty.channel.ChannelFuture;

@Component("springListener")
public class SpringListener implements ApplicationListener<ContextRefreshedEvent>{

	ExecutorService single = Executors.newSingleThreadExecutor();
	
	@Override
	public void onApplicationEvent(ContextRefreshedEvent event) {
	    if(event.getApplicationContext().getParent() == null){
	        //需要执行的逻辑代码，当spring容器初始化完成后就会执行该方法。  
	    	System.out.println("spring 加载完毕..");
			try {
				ExecutorService newSingleThreadExecutor = Executors.newSingleThreadExecutor();
				newSingleThreadExecutor.execute(new MainThread());
		 
			} catch (Exception e) {
				e.printStackTrace();
			}
	    }  		
		


	}



}
